package cn.txdnet.txcms.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;

/**
 * 用于存储页面记录显示信息
 *
 * @author txdnet
 */
public class PageDTO implements Serializable {

    private static final long serialVersionUID = 4935906600623907743L;
    /*
     *  页面记录数据
     */
    private Collection list;
    /*
     * 总记录数
     */
    private int rownum;
    /*
     * 额外信息存储
     */
    private Map<String, Object> extdata;

    public PageDTO() {
    }

    public PageDTO(Collection list, int rownum) {
        if (list == null) {
            this.list = Collections.emptyList();
        }
        this.list = list;
        this.rownum = rownum;
    }

    public PageDTO(Object[] list, int rownum) {
        if (list == null) {
            this.list = Collections.emptyList();
            return;
        }
        this.list = new ArrayList(list.length);
        Collections.addAll(this.list, list);
        this.rownum = rownum;
    }

    public PageDTO(Collection list, int rownum, Map<String, Object> extdata) {
        if (list == null) {
            this.list = Collections.emptyList();
        }
        this.list = list;
        this.rownum = rownum;
        this.extdata = extdata;
    }

    public PageDTO(Object[] list, int rownum, Map<String, Object> extdata) {
        if (list == null) {
            this.list = Collections.emptyList();
            return;
        }
        this.list = new ArrayList(list.length);
        Collections.addAll(this.list, list);
        this.rownum = rownum;
        this.extdata = extdata;
    }

    /**
     * @return the list
     */
    public Collection getList() {
        return list;
    }

    /**
     * @param list the list to set
     */
    public void setList(Collection list) {
        this.list = list;
    }

    /**
     * @return the extdata
     */
    public Map<String, Object> getExtdata() {
        return extdata;
    }

    /**
     * @param extdata the extdata to set
     */
    public void setExtdata(Map<String, Object> extdata) {
        this.extdata = extdata;
    }

    /**
     * @return the rownum
     */
    public int getRownum() {
        return rownum;
    }

    /**
     * @param rownum the rownum to set
     */
    public void setRownum(int rownum) {
        this.rownum = rownum;
    }
}
